<template>
  <div class="page" v-nav="{hideNavbar: true}" v-tabbar="{'menus': menus, menuColor: '#333', activeMenuColor: '#ff6816', }">
		<router-view></router-view>
  </div>
</template>
<script>
  export default {
    data() {
      return {
        menus: [],
      }
    },
    created:function(){
      if (sess.get('userSession')) {
        var resourceJson = sess.get('userSession').resourceList;

        if (resourceJson.length == 0) {
          this.$router.back('/login');
          $toast.show('您没有权限登录此系统！', 3000);
          return false;
        }

        for (var i = 0; i < resourceJson.length; i++) {
          var menuItem = {
            iconOn: 'ion-tab-'+resourceJson[i].resourceIcon,
            iconOff: 'ion-tab-'+resourceJson[i].resourceIcon+'-outline',
            text: resourceJson[i].resourceName,
            path: resourceJson[i].resourceUrl,
            badge:0
          }
          this.menus.push(menuItem);
        }
        if (!this.$store.state.loginIs) {
          this.$router.push(this.userSession.resourceList[0].resourceUrl)
          this.$store.commit('loginChange')
        }
      }else{
        this.$router.back('/login');
        $toast.show('请登录您的帐号！', 3000)
      }
    },
    computed: {
      userSession (){
        return sess.get('userSession')
      }
    },
    
    beforeDestroy() {
      $tabbar.$emit('hideTabbar')
    }
  }
</script>